const db =require("../lib/db")
function author(){
   
    return new Promise((resolve,reject)=>{
        let sql="select * from author";
        db.querySql(sql).then(data=>{
    // console.log(data)
    if(data.length==0){
        //返回状态码
    }else{
        //对数组做一个乱序处理
            let arr =data.sort(()=>0.5 - Math.random())
            // console.log(arr)
            let arr2=[]
            arr.map(element=>{
                //console.log(element)
                arr2.push({
                    _id:Buffer.from(String(element._Id)).toString("base64"),
                    userName:element.userName,
                    headImg:element.headImg,
                    descs:element.descs
                })
            })
           resolve(arr2)
           console.log(arr2)
        }
    })       
    })
}

//导出
module.exports=author